const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;

void async function () {
    line = await readline()
    let n = Number(line)
    line = await readline()
    let list = line.split(' ').map(Number)
    
    // 用栈来模拟入栈和出栈过程
    let stack = [];
    let res = []; //出错位置

    for (let i = 0; i < n; i++) {
        let num = list[i];
        if (num > 0) {
            stack.push(num);
        } else {  // 负数出栈
            // 毕竟需要弹出的数一定在栈顶
            let top = stack[stack.length - 1]
            if ( top === (-num)) {
                stack.pop();
            } else {
                res.push(i);
                // 寻找当前栈顶元素出栈下标
                let target = list.indexOf((-top));
                res.push(target)
                break
            }
        }
    }
    if (res.length === 2) {
        console.log(res[0] + 1, res[1] + 1);
    }
}();
// 20
// 14 16 13 -13 -16 1 -1 6 11 10 7 -7 -10 5 3 -3 -5 -14 -11 -6
// 20
// 11 14 16 13 -13 -16 1 -1 6 10 7 -7 -10 5 3 -3 -5 -14 -6 -11
// 8
// 3 -3 4 -2 2 -4 5 -5